package lexicalUnit;

import chalmersbot.Absyn.SpecialWordTokenSNounEsToken;
import chalmersbot.Absyn.SpecialWordTokenSNounSToken;
import chalmersbot.Absyn.SpecialWordToken.Visitor;

public class CheckSpecialWordToken implements Visitor<String, Environ> {

	@Override
	public String visit(SpecialWordTokenSNounSToken p, Environ env) {
		if (env.getFlag()==Environ.SUBJECT){
			if (p.snounstoken_.endsWith("s"))
				env.setPlural(true);
			if (p.snounstoken_.startsWith("building")){
				env.setKeywordClass(Environ.BUILDING);
				env.setPlural("building", "buildings");
				env.setSingular("buildings", "building");
			}
			else if (p.snounstoken_.startsWith("code")){
				env.setTarget(Environ.CODE);
				env.setPlural("code", "codes");
				env.setSingular("codes", "code");
			}
			else if (p.snounstoken_.startsWith("course")){
				env.setKeywordClass(Environ.COURSE);
				env.setPlural("course", "courses");
				env.setSingular("courses", "course");
			}
			else if (p.snounstoken_.startsWith("program")){
				env.setKeywordClass(Environ.PROGRAM);
				env.setPlural("program", "programs");
				env.setSingular("programs", "program");
			}
			else if (p.snounstoken_.startsWith("room")){
				env.setKeywordClass(Environ.ROOM);
				env.setPlural("room", "rooms");
				env.setSingular("rooms", "room");
			}
			else if (p.snounstoken_.startsWith("teacher")){
				env.setKeywordClass(Environ.PERSON);
				env.setPlural("teacher", "teachers");
				env.setSingular("teachers", "teacher");
			}
			else if (p.snounstoken_.startsWith("level")){
				env.setTarget(Environ.LEVEL);
				env.setPlural("level", "levels");
				env.setSingular("levels", "level");
			}
		}
		return p.snounstoken_;
	}

	@Override
	public String visit(SpecialWordTokenSNounEsToken p, Environ env) {
		if (env.getFlag()==Environ.SUBJECT){
			if (p.snounestoken_.startsWith("campus")){
				env.setKeywordClass(Environ.CAMPUS);
				env.setPlural("campus", "campuses");
				env.setSingular("campuses", "campus");
			}
		}
		return p.snounestoken_;
	}

}
